"Customer List" report

Our second report will be much more complicated than the first one (it will contain DB table data, a list of clients of a firm). To perform this, let us use the demonstration database DBDEMOS, which is included in the Delphi distribution kit. Let us create a new project in Delphi. Put the "TTable" component on the form and set its properties:

DatabaseName = 'DBDEMOS'
TableName = 'Customer.db'

For working with the table from FastReport, let us add the "TfrxDBDataSet" component, and then set its property:

DataSet = Table1

Finally, let us put "TfrxReport" (the basic componenet of FastReport) on the form, open the designer, and click the "New report" button, so that FastReport would automatically create a blank pattern with three bands ("Report title," "Master data," and "Page footer"). To make our table visible in FastReport, it is must be permitted to use it. To perform this, select the "Report|Data..." menu item and select the table (it is the only table in the list at the moment). After closing the dialog window, the table and its fields become visible in the "Data" service window.

Now let us settle down report form creating. Put the "Text" object with the "List of clients" text to the "Report title" band. After that, connect the "Master data" band to our data source. It can be performed in one of the following three ways:

- double-click on the band;
- select the "Edit..." item in the band contextual menu;
- click on the "DataSet" property in the object inspector.

Now we will place four objects (which would display a client’s number, a customer name, phone and fax) on the band. Let us do it in several different ways in order to demonstrate the features of the FastReport designer. Put the first "Text" object on the band and enter "[frxDBDataSet1."CustNo"]" to it. It is the most inconvenient way, since the link has to be enetered manually, and there is a possibility to enter the text incorrectly. To make inserting of such links into the text easier, we can use the expression designer (its button is located in the toolbar of the "Text" object editor). To insert our field, double-click on the required element in the opened dialogue. By clicking the "OK" button, we close the dialogue and see the field inserted into the text.

The second way of the DB field inserting into the report is quite similar to the one widely used in the Delphi environment; we will perform it with the help of property setting in the object inspector. Put the second object in the band, without writing anything in the editor. Let us set object properties in the inspector:

DataSet = frxDBDataSet1
DataField = 'Company'

Since both of the properties are presented as a list, we only need to select the required values with the help of the mouse.

The third way is to "drag and drop" the required field from the "Data" service window into the report. It is the most simple and obvious way. Take the "Phone" field with the help of the mouse, and then drag it to the band. The only one thing, which should be done in our case, is to disable the "Create header" flag at the bottom of the "Data" window (otherwise we would create a superfluous object, containing the field title, in addition to the required field).

Finally, here is the fourth way. Place a blank "Text" object on the band, and then move the cursor to the object. In the right part of the object you will see the image of the button with the down arrow (as in opening lists). This is the DB fields’ opening list. Click the button and select the "FAX" field in the list. You can use this feature when the band is connected to data.

Thus, our report is finished:

Click on the "Preview" button and see, what we have got.

Click on the "Preview" button and see, what we have got.